<link href="<?php echo base_url() ?>assets/css/pagination.css" rel="stylesheet" />

<div id="page-wrapper">

	<div class="container-fluid">

	    <!-- Page Heading -->
	    <div class="row">
	        <div class="col-lg-12">
	            <h1 class="page-header">
	                Hasil Marketing
	            </h1>
	            <ol class="breadcrumb">
	                <li>
	                    <i class="fa fa-dashboard"></i>  <a href="<?php echo base_url(); ?>home">Dashboard</a>
	                </li>
	                <li class="active">
	                    <i class="fa fa-edit"></i> Hasil Marketing
	                </li>
	            </ol>
	        </div>
	    </div>
	    <!-- /.row -->
		<div class="col-lg-8">
	            <h2>List Hasil Marketing</h2>
	            <form method="post" action="<?php echo base_url(); ?>modul/perusahaan/search">
					<input type="text" class="input-teks" size="70" value="<?php if($this->input->post('cari')) echo $this->input->post('cari'); else echo 'Cari Perusahaan...'; ?>" onblur="if(this.value=='') this.value='<?php echo 'Cari Perusahaan...'; ?>';" onfocus="if(this.value=='<?php echo 'Cari Perusahaan...'; ?>') this.value='';" name="cari"  />
					<input type="submit" value="Search" class="input-tombol" style="margin:0;padding: 9px 30px;" />
				</form>
	            <table class='table table-hover table-striped'>
					<thead>
					    <tr>
					      <th width='30px'>No</th>
					      <th>Nama perusahaan</th>
					      <th>Bidang Usaha</th>
					      <th>Setatus Marketing</th>
					    </tr>
					</thead>
					<?php $i = 1 ?>
                    <?php foreach($rows as $row): ?>
					<tr>
				        <td><?php echo $i ?></td>
			            <td><?php echo $row->nama_perusahaan ?></td>
			            <td><?php echo $row->kategori_perusahaan ?></td>
			            <td><?php 
                                        if($row->status_marketing_perusahaan == 'belum'){?>
                                            <button type="button" class="btn btn-sm btn-info" onClick="window.location='<?php echo base_url()?>modul/perusahaan/detail_sudah_marketing/<?php echo $row->id_perusahaan?>'"><i class="icol-magnifier"></i>Belum</button>
                                        <?php } 
                                        elseif ($row->status_marketing_perusahaan == 'positif') { ?>
                                            <button type="button" class="btn btn-sm btn-primary" onClick="window.location='<?php echo base_url()?>modul/perusahaan/detail_sudah_marketing/<?php echo $row->id_perusahaan?>'"><i class="icol-magnifier"></i>Positif</button>
                                        <?php }
                                        elseif ($row->status_marketing_perusahaan == 'negatif') { ?>
                                            <button type="button" class="btn btn-sm btn-warning" onClick="window.location='<?php echo base_url()?>modul/perusahaan/detail_sudah_marketing/<?php echo $row->id_perusahaan?>'"><i class="icol-magnifier"></i>Negatif</button>
                                        <?php }
                                        elseif ($row->status_marketing_perusahaan == 'success') { ?>
                                            <button type="button" class="btn btn-sm btn-success" onClick="window.location='<?php echo base_url()?>modul/perusahaan/detail_sudah_marketing/<?php echo $row->id_perusahaan?>'"><i class="icol-magnifier"></i>Success</button>
                                        <?php } 
                                        else { ?>
                                            <button type="button" class="btn btn-sm btn-danger" onClick="window.location='<?php echo base_url()?>modul/perusahaan/detail_sudah_marketing/<?php echo $row->id_perusahaan?>'"><i class="icol-magnifier"></i>Failed</button>
                                           <?php }?></td>
				    </tr> 
				    <?php $i++; ?>
                    <?php endforeach ?>  
				<br />
	    </div>
	</div>
	<!-- /.row -->

</div>
<!-- /.container-fluid -->


<script>
$(document).ready(function() {
	function loading_show() {
		$('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast');
	}
	function loading_hide() {
		$('#loading').fadeOut('fast');
	}
	function loadData(page) {
		loading_show();
		$.ajax
		({
			type: "get",
			url: "<?php echo base_url() ?>modul/perusahaan/pagination",
			data: "page=" + page, 
			success: function(msg)
			{
				$("#content").ajaxComplete(function(event, request, settings)
				{
					loading_hide();
					$("#content").html(msg);
				});
			}
		});
	}
        loadData(1);  // For first time page load default results
        $('#content .pagination li.active').live('click', function() {
        	var page = $(this).attr('p');
        	loadData(page);

        });
        $('#go_btn').live('click', function() {
        	var page = parseInt($('.goto').val());
        	var no_of_pages = parseInt($('.total').attr('a'));
        	if (page != 0 && page <= no_of_pages) {
        		loadData(page);
        	} else {
        		alert('Enter a PAGE between 1 and ' + no_of_pages);
        		$('.goto').val("").focus();
        		return false;
        	}

        });
    });

</script>
